package com.kaoshidian.front.mongodb;

import com.kaoshidian.front.mongodb.base.BaseManage;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

public class PopCourseManager extends BaseManage {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PopCourseManager manager = new PopCourseManager();
		manager.mainBody("PopularityCourse");
	}

	@Override
	public void treate(DBCollection coll) {
		updateCritique(coll);
	}

	public void updateCritique(DBCollection coll) {
		DBCursor cur = coll.find();
		while (cur.hasNext()) {
			DBObject cool = cur.next();
			DBObject critique = (DBObject) cool.get("critique");
			if (critique.containsField("commentState")) {
				critique.removeField("commentState");
			}
			{
				String signtop = (String) critique.get("signtop");
				if (signtop.equals("COMMON")) {
					critique.put("signtop", "UN_SIGNTOP");
				}
			}
			coll.save(cool);
		}
	}
}
